import {drizzle} from 'drizzle-orm/mysql2'
import {createPool} from 'mysql2'
import * as schema from '../schema/schema'
import * as relations from '../schema/relations'

const poolConn = createPool({
  user: 'root',
  password: 'xzm525238xzm.',
  host: 'elysia-blog-mysql',
  port: 3306,
  database: 'rish'
})
const db = drizzle(poolConn, {
  logger: {
    logQuery(query, params) {
      console.log('[drizzle Query]:', query, params)
    },
  },
  schema: { ...schema, ...relations }, mode: 'default'
})

export default db

export type DB = typeof db